<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #create_time="{ record }">
        {{ tool.dateFormat(record.create_time, 'yyyy-MM-dd hh:mm:ss', '-') }}
      </template>
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import recordPaymentSuccess from '@/api/record/recordPaymentSuccess'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  recordPaymentSuccess.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  recordPaymentSuccess.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'record_payment_success',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: false,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: recordPaymentSuccess.getList,
  recycleApi: recordPaymentSuccess.getRecycleList
})

const columns = reactive([
  {
    title: "Id",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入Id"
    }
  },
  {
    title: "用户id",
    dataIndex: "user_id",
    formType: "input",
    search: true,
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入用户id"
    }
  },
  {
    title: "上级ID",
    dataIndex: "parent_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入上级ID"
    }
  },
  {
    title: "用实际到账",
    dataIndex: "fact_money",
    formType: "input"
  },
  {
    title: "到账金额",
    dataIndex: "received_amount",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入到账金额"
    }
  },
  {
    title: "内部订单号",
    dataIndex: "order_sn",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入内部订单号"
    }
  },
  {
    title: "外部订单号",
    dataIndex: "transaction_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入外部订单号"
    }
  },
  {
    title: "支付方式",
    dataIndex: "method_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入支付方式"
    }
  },
  {
    title: "支付名称",
    dataIndex: "method_name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入支付名称"
    }
  },
  {
    title: "创建人",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "create_time",
    width:180,
    formType: "range",
    search: true,
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "修改时间",
    dataIndex: "update_time",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'record:paymentSuccess' } </script>